Ext.define('js.schedule.scheduleShowPage', {
    extend: 'Ext.grid.Panel',
    id:'scheduleShowPage',
    requires: ['js.Util', 'js.ctrl.Common',],
    controller: 'Common',
    autoScroll : true,
    margin:'20 30 30 30',
    height:642,
    bodyStyle: {
        backgroundColor: '#eee',
    },
    initComponent: function () {
        this.store = Ext.create('js.store.Object.scheduleListStore');
        this.store.getProxy().setExtraParam('pageNum', 1);
        this.store.load({
            callback:function () {
                let me = Ext.getCmp('scheduleShowPage');
                if(me){
                    if(me.store.data.items.length>0){
                        new Page({
                            id: 'paginationSupplierABC',
                            pageTotal: me.store.data.items[0].data.pageTotal, //必填,总页数
                            pageAmount: 10,  //每页多少条
                            dataTotal: me.store.data.items[0].data.dataTotal, //总共多少条数据
                            curPage:parseInt(me.store.data.items[0].data.pageNum), //初始页码,不填默认为1
                            pageSize: 5, //分页个数,不填默认为5
                            showPageTotalFlag:true, //是否显示数据统计,不填默认不显示
                            showSkipInputFlag:true, //是否支持跳转,不填默认不显示
                            getPage: function (page) {
                                //获取当前页数
                                me.store.getProxy().setExtraParam('pageNum', page);
                                me.store.reload();
                            }
                        })
                    }else{
                        new Page({
                            id: 'paginationSupplierABC',
                            pageTotal: 1, //必填,总页数
                            pageAmount: 10,  //每页多少条
                            dataTotal: 0, //总共多少条数据
                            pageSize: 5, //分页个数,不填默认为5
                            showPageTotalFlag:true, //是否显示数据统计,不填默认不显示
                            showSkipInputFlag:true, //是否支持跳转,不填默认不显示
                            getPage: function (page) {
                                //获取当前页数
                                me.store.getProxy().setExtraParam('pageNum', page);
                                me.store.reload();
                            }
                        })
                    }
                }
            }
        });
        this.columns = [
            {text: '编号', dataIndex: 'engineering_no', align: 'center', flex: 1},
            {text: '日期', dataIndex: 'inspection_date', align: 'center', flex: 1,},
            {text: '工程名称', dataIndex: 'engineering_name', align: 'center', flex: 1,},
            {text: '验收节点', dataIndex: 'parent_name', align: 'center', flex: 1,},
            {text: '子节点', dataIndex: 'child_name', align: 'center', flex: 2,},
            {text: '报建人员及电话', dataIndex: 'reporter_information', align: 'center', flex: 2,},
            {text: '监督人员', dataIndex: 'supervisor_name', align: 'center', flex: 1},
            {text: '状态', dataIndex: 'progress_status', align: 'center', flex: 1},
            {
                text: "操作",
                flex:1,
                align: 'center',
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {//自定义列值组合

                    return '<span style="margin-right:20px;color:#2672d9;font-size: 17px;letter-spacing: 1px;cursor:pointer;"><a href="#"  style="text-decoration:none;" onclick="xiangqinggcjdysjdupd(' + JSON.stringify(record.data).replace(/\"/g, "'") + ')">详情</a></span>';
                },height:44
            }

        ];
        this.dockedItems = [
            {
                dock: 'top',
                xtype: 'toolbar',
                border:'none',
                margin:'0 0 0 0',
                items: [{
                    xtype: 'panel',
                    ui: 'threshold1',
                    bodyStyle:{
                        background:'#eee'
                    },
                    width:'100%',
                    margin:'0 0 0 -21px',
                    height: 95,
                    border: false,
                    layout: 'vbox',
                    items:[
                        {
                            xtype:'panel',
                            height:45,
                            width:'100%',
                            layout: 'hbox',
                            bodyStyle:{
                                background:'#eee'
                            },
                            items:[
                                {
                                    xtype: 'combobox',
                                    height: 30,
                                    width:'25%',
                                    emptyText: '工程名称',
                                    id:'gcmca',
                                    margin:'0 58% 10 29%',
                                    triggerAction: 'all',
                                    editable: false,
                                    displayField: 'dataType',
                                    valueField: 'value',
                                    store:  Ext.create('js.store.wide.engineering_filter'),
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let me = Ext.getCmp('scheduleShowPage');
                                            me.store.getProxy().setExtraParam('engineering_filter', newValue);
                                            me.store.reload();
                                        }
                                    }
                                },{
                                    xtype: 'combobox',
                                    emptyText: '验收节点',
                                    id:'ysjda',
                                    triggerAction: 'all',
                                    height: 30,
                                    width: '25%',
                                    margin:'0 58% 0 29%',
                                    labelSeparator: '',
                                    labelWidth: 70,
                                    editable: false,
                                    displayField: 'dataType',
                                    valueField: 'value',
                                    store:  Ext.create('js.store.wide.node_filter'),
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let me = Ext.getCmp('scheduleShowPage');
                                            me.store.getProxy().setExtraParam('node_filter', newValue);
                                            me.store.reload();
                                        }
                                    }
                                },{
                                    xtype: 'combobox',
                                    height: 30,
                                    emptyText: '监督人员',
                                    id:'jdrya',
                                    margin:'0 58% 0 29%',
                                    width: '25%',
                                    labelSeparator: '',
                                    labelWidth: 70,
                                    editable: false,
                                    displayField: 'dataType',
                                    valueField: 'value',
                                    store:  Ext.create('js.store.user.userSelStore',{
                                        proxy: {
                                            extraParams: {
                                                type: 0,
                                            },
                                        }
                                    }),
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let me = Ext.getCmp('scheduleShowPage');
                                            me.store.getProxy().setExtraParam('supervisor_filter', newValue);
                                            me.store.reload();
                                        }
                                    }
                                },{
                                    xtype: 'combobox',
                                    height: 30,
                                    emptyText: '工程状态',
                                    margin:'0 58% 0 29%',
                                    id:'gczta',
                                    width: '25%',
                                    labelSeparator: '',
                                    labelWidth: 70,
                                    editable: false,
                                    displayField: 'dataType',
                                    valueField: 'value',
                                    store:  Ext.create('js.store.wide.projectStateA'),
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let me = Ext.getCmp('scheduleShowPage');
                                            me.store.getProxy().setExtraParam('progressStatus_filter', newValue);
                                            me.store.reload();
                                        }
                                    }
                                }
                            ]},
                        {
                            xtype:'panel',
                            height:40,
                            width:'100%',
                            layout: 'hbox',
                            bodyStyle:{
                                background:'#eee'
                            },
                            items:[
                                {
                                    xtype: 'component',
                                    html: `<span style="font-size:14px;">日期范围:</span>`,
                                    margin:'9 0 0 29%',
                                    width:'6%',
                                    height: '100%'

                                },{
                                    xtype: 'datefield',
                                    name: 'startDateA',
                                    id:'kgrqfw',
                                    width:'21%',
                                    height: 30,
                                    editable:false,
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let startDateB= Ext.getCmp('jsrqfw').getValue();
                                            let me = Ext.getCmp('scheduleShowPage');
                                            Ext.getCmp('jsrqfw').setMinValue(new Date(newValue));
                                            me.store.getProxy().setExtraParam('startDateB', startDateB);
                                            me.store.getProxy().setExtraParam('startDateA', newValue);
                                            me.store.reload();
                                        }
                                    }
                                },{
                                    xtype: 'component',
                                    html: `<span style="color:#2672d9;font-weight: bold;"> ---- </span>`,
                                    margin:'9 -10 0 5',
                                    width:'4%',
                                    height: '100%',
                                },{
                                    xtype: 'datefield',
                                    name: 'startDateB',
                                    id:'jsrqfw',
                                    width:'21%',
                                    height: 30,
                                    editable:false,
                                    listeners: {
                                        change: function (com, newValue, oldValue, eOpts) {//企业ID
                                            let startDateA= Ext.getCmp('kgrqfw').getValue();
                                            let me = Ext.getCmp('scheduleShowPage');
                                            me.store.getProxy().setExtraParam('startDateB', newValue);
                                            me.store.getProxy().setExtraParam('startDateA', startDateA);
                                            me.store.reload();
                                        }
                                    }
                                },
                                 {
                                     xtype : "button",
                                     text:'刷新',
                                     cls:'button-Intelligent-sensor',
                                     style:"cursor:pointer",
                                     margin:'0 5% 0 29%',
                                     handler: this.refresh,
                                     scope: this,
                                     width: '9.5%',
                                     height: 32,
                                 }
                            ]}
                    ]

                }]

            },{
                xtype: 'panel',
                html:'<div id="paginationSupplierABC" class="pagination"></div>',
                dock: 'bottom',
                height:50,
                margin:'-14 0 0 0',
                displayInfo: true,
            }]
        this.callParent(arguments);
    },
      refresh: function (btn) {
          Ext.getCmp('gcmca').setValue('');
          Ext.getCmp('ysjda').setValue('');
          Ext.getCmp('jdrya').setValue('');
          Ext.getCmp('jsrqfw').setValue('');
          Ext.getCmp('kgrqfw').setValue('');
          Ext.getCmp('gczta').setValue('');
          this.getStore().reload();
      }
});